//
//  SmallDecisionsXjdTemplateTitleCell.m
//  SmallDecisions
//
//  Created by 李付雄 on 2025/8/4.
//

#import "SmallDecisionsXjdTemplateTitleCell.h"

@implementation SmallDecisionsXjdTemplateTitleCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style
              reuseIdentifier:(NSString *)reuseIdentifier {
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = [UIColor clearColor];
        
        [self createSmallDecisionsXjdTemplateTitleCellSubviews];
    }
    return self;
}

- (void)createSmallDecisionsXjdTemplateTitleCellSubviews {
    [self templateTitleBtn];
    [self textField];
}

- (UIButton *)templateTitleBtn {
    if(!_templateTitleBtn) {
        _templateTitleBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _templateTitleBtn.titleLabel.font = SmallDecisionsSetFontSize(18);
        _templateTitleBtn.backgroundColor = SmallDecisionsSecondBgColor;
        [_templateTitleBtn setTitle:@"🤔" forState:UIControlStateNormal];
        _templateTitleBtn.layer.cornerRadius = 8;
        [self.contentView addSubview:_templateTitleBtn];
        [_templateTitleBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(15);
            make.left.mas_equalTo(20);
            make.bottom.mas_equalTo(-15).priorityHigh();
            make.width.height.mas_equalTo(56);
        }];
    }
    
    return _templateTitleBtn;
}

- (SmallDecisionsTextField *)textField {
    if(!_textField) {
        _textField = [[SmallDecisionsTextField alloc] init];
        _textField.textColor = SmallDecisionsThemeFontColor;
        _textField.placeholder = @"请输入选项";
        _textField.layer.cornerRadius = 8;
        _textField.leadingViewRect = CGRectMake(0, 0, 10, 56);
        _textField.trailingViewRect = CGRectMake(0, 0, 10, 56);
        _textField.layer.masksToBounds = YES;
        _textField.backgroundColor = SmallDecisionsSecondBgColor;
        _textField.font = SmallDecisionsSetFontSize(16);
        [self.contentView addSubview:_textField];
        [_textField mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(15);
            make.bottom.mas_equalTo(-15);
            make.left.mas_equalTo(self.templateTitleBtn.mas_right).mas_offset(10);
            make.right.mas_equalTo(-15);
        }];
    }
    return _textField;
}


@end
